/**
 * @Author: 陈瑞鹏
 * @Date:   2022-12-05 17:39:01
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-12-05 17:42:46
 */
import { Mediator } from "../pureMvc/patterns/mediator/Mediator";
import BaseGameLayer from "./BaseGameLayer";
import { INotification } from "../pureMvc/Interfaces";
import { GameFacade } from "./GameFacade";

export class MediatorGameLayer extends Mediator {
  private displayObject: BaseGameLayer = null;
  public constructor(mediatorName: string, displayObject: BaseGameLayer) {
    super(mediatorName);
    this.bindingDisplayObject(displayObject);

  }

  public registerMediator(): void {
    GameFacade.getInstance().registerMediator(this);
  }

  public removeMediator(): void {
    GameFacade.getInstance().removeMediator(this.getMediatorName());
  }

  private bindingDisplayObject(displayObject: BaseGameLayer): void {
    this.displayObject = displayObject;
  }

  public listNotificationInterests(): string[] {
    return this.displayObject.listNotificationInterests();
  }

  public handleNotification(notification: INotification): void {
    this.displayObject.handleNotification(notification);
  }
}